<?php
/*
Description:
	Member related functions

Function List:
1	login_user($username,$password)
2	logout()
3	register_member($username,$password,$email)

*/


//include("../DAL/DB_Queries.php");

//1------------------------------------------------------------------------------------------------1

function login_user($username,$password)
{
	include("Libraries/Dal/DB_Queries.php");
	
	if($username!="" && $password!="")
	{
		if(login($username,$password)==true)//klisi function apo tier1
		{   
			return 0;
		}
		else
		{
			return 1;
		}
	}
	else
		return 2;
}	


//2------------------------------------------------------------------------------------------------2

function logout()
{  
	session_destroy();
}	
	
//3------------------------------------------------------------------------------------------------3
function register_member($username,$password,$email)
{
	include("Libraries/Dal/DB_Queries.php");   
	if (check_user_exists($username)==true)//klisi function apo tier1
	{
		return 0;
	}
	else
	{
		if($username!="" && $password!="" && $email!="")
		{
			
			//$username,$password,$email,$type_id
			insert_into_member($username,$password,$email,"member");//klisi function apo tier1
			return 1;
		}
		else
		{
			return 2;
		}
	}	
}
//------------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------------
?>